/************************************************************************/
/*																		*/
/*			Autor: Dobromir Todorov										*/
/*			Email: dobromir.todorov.todorov@gmail.com                   */
/*																		*/
/************************************************************************/
//#include "stdafx.h"
#include <Ogre.h>
#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include <OISMouse.h>

class ObjectControl
{

public:
	enum Type
	{
		Move_Mode,
		Scale_Mode,
		Rotate_Mode,
		MoveX,
		MoveY,
		MoveZ,
		RotateX,
		RotateY,
		RotateZ,
		ScaleX,
		ScaleY,
		ScaleZ,
		ScaleXYZ,
	};
	ObjectControl(Ogre::SceneManager* _mSceneMgr,Ogre::Camera* _mCamera):
		mRaySceneQuery(0),widget(0),node(0),currentMode(Move_Mode),currntOperation(0)
		{
			mSceneMgr=_mSceneMgr;
			mCamera= _mCamera;
		}
		~ObjectControl(void);
		void init();
		Ogre::MovableObject* getNode(float mouseScreenX, float mouseScreenY);
		void selectObjectForEdit(const char* idObject, char* type);
		void update();
		void mousePressed(const OIS::MouseEvent &arg);
		void mouseReleased();
		void mouseDragged(const OIS::MouseEvent &arg);
		Ogre::SceneNode* GetNode(){return node;}
		void switchMode(int);
		void RemoveSelection();
		void AddMavableFlag(unsigned int iflag){mMovableFlagSet.push_back(iflag);}
		void RemoveMavableFlag(unsigned int iflag);

protected:

	Ogre::SceneManager* mSceneMgr;
	Ogre::Camera* mCamera;
	Ogre::RaySceneQuery* mRaySceneQuery;	//pointer to our ray scene query
	Ogre::SceneNode* widget;
	Ogre::SceneNode* node;
	float MouseX,MouseY;
	int currntOperation;
	Ogre::SceneNode* planeXNode;
	Ogre::SceneNode* planeYNode;
	Ogre::SceneNode* planeZNode;
	int currentMode;
	std::vector<unsigned int> mMovableFlagSet;

	bool ObjIsMoveable(Ogre::MovableObject* obj);


};